package com.xbai.entity;

import lombok.Data;

/**
 * 返回结果实体类
 * @author xbai
 * @Date 2021/1/27
 */
@Data
public class Result<T> {

    /**
     * 是否成功
     */
    private Boolean flag;
    /**
     * 返回码
     */
    private Integer code;

    /**
     * 返回消息
     */
    private String message;

    /**
     * 返回数据
     */
    private T data;

    public Result(Boolean flag, Integer code, String message, Object data) {
        this.flag = flag;
        this.code = code;
        this.message = message;
        this.data = (T) data;
    }

    public Result(Boolean flag, Integer code, String message) {
        this.flag = flag;
        this.code = code;
        this.message = message;
    }

    public Result(Object data) {
        this.data = (T) data;
        this.flag = true;
        this.code = StatusCode.OK;
        this.message = "成功";
    }

    public Result() {
        this.flag = true;
        this.code = StatusCode.OK;
        this.message = "成功";
    }

}
